package 面试经典150题.双指针;
/**
 *@author tmh
 *@date  2024/4/5 16:38
 *@description
 */
public class T125验证回文字符串 {

    public static void main(String[] args) {

    }

    public boolean isPalindrome(String s) {
        //这个考察的主要是对于Character的api的使用
        StringBuilder stringBuilder=new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if(Character.isLetterOrDigit(c)){
                stringBuilder.append(Character.toLowerCase(c));
            }
        }
        StringBuilder sReverse=new StringBuilder(stringBuilder).reverse();
        if(stringBuilder.toString().equals(sReverse.toString())){
            return true;
        }
        return false;
    }
}
